import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 * 字符串分割
 */
public class SplitString {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int num = Integer.parseInt(scanner.nextLine());
            List<String> result = new LinkedList<>();
            for (int i=0; i<num; i++) {
                String line = scanner.nextLine();
                if (line.length() < 8) {
                    result.add(completion(line));
                } else {
                    for (int j = 0; j < line.length(); j += 8) {
                        if (j + 8 > line.length()) {
                            result.add(completion(line.substring(j)));
                        } else {
                            result.add(line.substring(j, j+8));
                        }
                    }
                }
            }
            result.forEach(System.out::println);
        }
    }

    private static String completion(String string) {
        StringBuffer sb = new StringBuffer(string);
        int length = sb.length();
        for (int i=0; i<8-length; i++) {
            sb.append("0");
        }
        return sb.toString();
    }
}
